/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ens.delegation.servlet;

import java.io.IOException;
import javax.servlet.*;

/**
 *
 * @author amine
 */
public class EncodingFilter implements Filter{

    private String encoding;
    
    @Override
    public void init(FilterConfig fc) throws ServletException {
        this.encoding = fc.getInitParameter("encoding");
    }

    @Override
    public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) throws IOException, ServletException {
        sr.setCharacterEncoding(encoding);
        sr1.setCharacterEncoding(encoding);
        fc.doFilter(sr, sr1);
    }

    @Override
    public void destroy() {
    }
    
}
